<?php 

session_start();
require_once '../data/connect.class.php';

$userName =  $_POST['userName'];
$password =  $_POST['password'];

if (isset($userName) && isset($password) && strlen($userName) > 0 && strlen($password) > 0 ) {
	
	$connect = new Connect("localhost","root","","email");

    $userSql = "select * from admin_user where name='$userName' and password='$password'";
    $resultSet = $connect->Query("$userSql");
    if ($connect->getNum() > 0){
    	$_SESSION['suser']=$userName;
    	$_SESSION['userId']=$resultSet[0]['id'];
    	echo "<script>location.href='/pages/page_main.php'</script>";
    	
    	
    } else {
    	echo "<script>alert('登陆失败');location.href='/pages/Login.php'</script>";
    }
	
} else {
	
	echo "<script>alert('用户名或密码不能为空');location.href='/pages/Login.php'</script>";
}
?>